<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>AccessToWeatherEver</title>
    </h:head>
    <h:body>
        <h:form id="loginform">
            <p:panel header="Login Form">
                <p:panelGrid columns="2">
                    <p:outputLabel for="email" value="Email"/>
                    <p:inputText id="email" value="#{loginBean.emailAddress}" 
                                 required="true" />
                    <p:outputLabel for="pass" value="Password"/>
                    <p:password id="pass" value="#{loginBean.password}" 
                                required="true" />
                    <p:commandButton id="submit" action="#{loginBean.login()}" value="Login" ajax="true" update="@all"/>
                </p:panelGrid>
            </p:panel>
            <h:messages  style="color: red"/>
        </h:form>
        
        <h:form id="registrationform">
            <p:panel header="Registration Form">
                <h:panelGrid columns="3" id="regGrid">
                    <h:outputLabel for="emailAddress">Email:</h:outputLabel>
                    <p:inputText id="emailAddress" value="#{registrationBean.user.emailAddress}" >
                        <p:ajax update="emailAddressmsg"/>
                    </p:inputText>
                    <p:message id="emailAddressmsg" for="emailAddress" />
                    
                    <h:outputLabel for="password">Password:</h:outputLabel>
                    <p:password id="password" value="#{registrationBean.user.password}"
                                feedback="true" match="pwd2" label="Password"/>
                    <p:message for="password" />
                    
                    <h:outputLabel for="pwd2">Confirm Password:</h:outputLabel>
                    <p:password id="pwd2" label="Confirm Password"/>
                    <br></br>
                    
                    <h:outputLabel for="privacy">Privacy:</h:outputLabel>
                    <p:inputSwitch id="privacy" value="#{registrationBean.user.privacy}"/>
                    <br></br>
                <p:commandButton id="submit" value="Register" update="regGrid"
                                 action="#{registrationBean.register()}" />
                </h:panelGrid>
            </p:panel>
        </h:form>

    </h:body>
</html>

